import Taro from "@tarojs/taro";
import { View, Image } from "@tarojs/components";
import log from "../../assets/images/app_log.png";
import sign from "../../assets/images/app_sign.png";
import "./index.scss";
export default () => {
    const charts = [
        {
            name: "多图表",
            url: "../multipleCharts/index",
            logo: log,
        },
        {
            name: "切页",
            url: "../cutoPageChart/index",
            logo: sign,
        },
    ];
    const person = [
        {
            name: "博客",
            url: "../WebView/index",
            WebViewUrl: 'https://i.csdn.net/#/user-center/profile?spm=1011.2124.3001.5111',
            WebViewTitle: '个人博客',
            goToWebView: true,
            logo: log,
        },
        {
            name: "项目地址",
            url: "../WebView/index",
            WebViewUrl: 'https://i.csdn.net/#/user-center/profile?spm=1011.2124.3001.5111',
            WebViewTitle: '项目地址',
            goToWebView: true,
            logo: log,
        },
    ]
    const works = [
        {
            name: "日报",
            url: "../worksList/index",
            logo: log,
        },
        {
            name: "周报",
            url: "../worksList/index",
            logo: sign,
        },
    ];
    const goToPage = (item) => {
        const { url, goToWebView, WebViewUrl, WebViewTitle } = item;
        if (goToWebView) {
            Taro.navigateTo({
                url: `${url}?goToWebViewUrl=${WebViewUrl}&&WebViewTitle=${WebViewTitle}`,
            });
        } else {
            Taro.navigateTo({
                url: `${url}`,
            });
        }

    };
    const renderItem = (arr) => {
        return arr?.map((item) => {
            return (
                <View
                    className="item"
                    key={item.name}
                    onClick={() => goToPage(item)}
                >
                    <Image src={item.logo} />
                    <View>{item.name}</View>
                </View>
            );
        });
    };
    return (
        <View className="container">
            <View className="sales-money">
                <View className="sales-money-title">
                    <View className="sales-money-title-text">个人介绍</View>
                </View>
                {renderItem(person)}
            </View>
            <View className="sales-money">
                <View className="sales-money-title">
                    <View className="sales-money-title-text">工作</View>
                </View>
                {renderItem(works)}
            </View>
            <View className="sales-money">
                <View className="sales-money-title">
                    <View className="sales-money-title-text">图表</View>
                </View>
                {renderItem(charts)}
            </View>
        </View>
    );
};
